<script setup lang="tsx">
import { PropType, ref, onMounted } from 'vue'
import { Descriptions, DescriptionsSchema } from '@/components/Descriptions'
import { Icon } from '@/components/Icon'
import { ElTag } from 'element-plus'
import { orgTypeData } from './index'

const props = defineProps({
  currentRow: {
    type: Object as PropType<any>,
    default: () => undefined
  }
})
const detailInfo = ref({})

const renderTag = (enable?: boolean) => {
  return <ElTag type={!enable ? 'danger' : 'success'}>{enable ? '启用' : '禁用'}</ElTag>
}

const detailSchema = ref<DescriptionsSchema[]>([
  {
    field: 'parent.name',
    label: '父级节点'
  },
  {
    field: 'name',
    label: '机构名称'
  },
  {
    field: 'orgType',
    label: '机构类型',
    slots: {
      default: (data: any) => {
        const val = orgTypeData.find((item) => item.value === data.orgType)?.label
        return <>{val}</>
      }
    }
  },
  {
    field: 'shortname',
    label: '机构简称'
  },
  {
    field: 'legal',
    label: '机构法人'
  },
  {
    field: 'telephone',
    label: '法人联系方式'
  },

  {
    field: 'createTime',
    label: '创建时间'
  },
  {
    field: 'createUser',
    label: '创建人'
  },
  {
    field: 'createTime',
    label: '修改时间'
  },
  {
    field: 'updateUser',
    label: '修改人'
  },
  {
    field: 'sortOrder',
    label: '显示排序'
  }
])
</script>

<template>
  <Descriptions :schema="detailSchema" :data="currentRow || {}" />
</template>
